#create
c='a'+'b'
'ab'
#find
content='asdfghjkl'
content.find('s')
1
content.find('z')
-1
content.find('zs')
-1
#index
content='asdfghjkl'
content.index('s')
1
content.index('zs')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: substring not found
content.index('z')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: substring not found
#startswith/endswith
content.startswith('d')
False
content.startswith('ad')
False
content.startswith('asd')
True
#索引
content='asdfghjkl'
len(content)
9
content[4]
'g'
content[3:6]
'fgh'
#replace
content='aassddaa'
content.replace('a','z')
'zzssddzz'
#split分割
content.split('d')
['aass', '', 'aa']
content.split('dd')
['aass', 'aa']
#join
"   ".join(c)
'aass   aa'
#delete
"  hello world!".strip()
'hello world!'
"  hello world!".rstrip()
'  hello world!'
#strip巧用
content='[1,2,3,4]'
>>> content.strip('[]')
'1,2,3,4'
#format按传入参数的默认顺序
'{}-10-{}'.format(2020,25)
'2020-10-25'
#format按指定参数索引
'{0}, {1}, {0}'.format('ping','pang')
'ping, pang, ping'
#format按关键词参数
'{country}-{city}'.format(country='China',city='shanghai')
#format按变量
country='China'
f'{country}-shanghai'
'China-shanghai'
#format处理浮点数
'{:.2f}'.format(3.1415926)
'3.14'
'{:.2}'.format(3.1415926)
'3.1'
'{:.211}'.format(3.1415926)
'3.14159260000000006840537025709636509418487548828125'
>>> '{:.11}'.format(3.1415926)
'3.1415926'
>>> '{:.18}'.format(3.1415926)
'3.14159260000000007'
